﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using DTO;
using BUS;

namespace GUI
{
    public partial class frmChiTietPhieuBanHang : DevComponents.DotNetBar.Metro.MetroForm
    {
        public frmChiTietPhieuBanHang()
        {
            InitializeComponent();
        }

        private void frmChiTietPhieuBanHang_Load(object sender, EventArgs e)
        {
            LoadChiTietPhieuBanHang(frmMain.mahoadon);
        }

        private void LoadChiTietPhieuBanHang(int mahoadon)
        {
            HoaDonBUS hdbus = new HoaDonBUS();
            HoaDonDTO hddto = hdbus.LayThongTinHoaDon(mahoadon);
            ChiTietHoaDonBUS cthdbus = new ChiTietHoaDonBUS();
            ThietBiBUS tbbus = new ThietBiBUS();
            List<ChiTietHoaDonDTO> ds = cthdbus.LayDanhSachChiTietHoaDonTheoMaHoaDon(mahoadon);
            for (int i = 0; i < ds.Count; i++)
            {
                dgvChiTietPhieuBanHang.Rows.Add(i + 1, tbbus.LayThongTinThietBi(ds[i].MaThietBi).TenThietBi, ds[i].SoLuong, string.Format("{0:#,0.#}", ds[i].DonGia), string.Format("{0:#,0.#}", ds[i].ThanhTien));
            }
            txtTongTien.Text = string.Format("{0:#,0.#} VNĐ", hddto.TongTien);
            if (hddto.GhiChu != "")
                txtGhiChu.Text = hddto.GhiChu;
            else
                txtGhiChu.Text = "Ghi chú...";
        }
    }
}